package dk.ahp.opgave3;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebView;
import android.widget.EditText;
import android.widget.TextView;
import android.support.v4.app.NavUtils;

public class opgave3 extends Activity {
	private EditText et;
	private TextView tv;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_opgave3);
        et = (EditText) findViewById(R.id.editText1);
        tv = (TextView) findViewById(R.id.textView1);
        return;
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
//        getMenuInflater().inflate(R.menu.activity_opgave3, menu);
    	menu.add(Menu.NONE, 101, Menu.NONE, R.string.openURL);
    	menu.add(Menu.NONE, 102, Menu.NONE, "Tilbage");
        return true;
    }

    public boolean onOptionsItemSelected(MenuItem item)
    {
    	if (101 ==item.getItemId())
    	{
    		WebView wv = new WebView(this);
    		String url = et.getText().toString();
    		if (url.length()>0)
    			{
    				wv.loadUrl(url);
    			}
    		else
    		{
    			wv.loadUrl("http://m.jyllands-posten.dk");
    		}
    		setContentView(wv);
    	}
    	else if (102 == item.getItemId())
    	{
    		setContentView(R.layout.activity_opgave3);
    	}
    	return true;
    }
}
